import javax.swing.*;
import java.awt.*;
    public class GameFrame extends JFrame {
        final int frameSize = 600;
        final int step = 30;
        public  void launch(){
            this.setTitle("贪吃蛇");
            this.setSize(frameSize, frameSize);
            this.setLocationRelativeTo(null);
            this.setVisible(true);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\
            snakHead.paintSelf(graphics);
            while (true){
                repaint();
                try{
                    Thread.sleep(200);
                }catch (InterruptedException e){
                    e.printStackTrace();
                }

            }
        }


        public SnakeHead snakHead = new SnakeHead(30,570,GameUtils.rightImg);
        public void paint (Graphics graphics){
            graphics.setColor(Color.lightGray);
            graphics.fillRect(0,0,frameSize,frameSize);
            graphics.setColor(Color.yellow);
//            graphics.drawRect(0,30,600,30);
//            graphics.drawRect(0,60,600,60);
//            graphics.drawRect(0,60,300,300);
//            graphics.fillRect(100,100,300,300);
            int lineNum = frameSize / step;
            for(int i = 0; i < lineNum;i++){
                graphics.drawLine(0,i*step,frameSize,i*step);
                graphics.drawLine(i*step,0,i*step,frameSize);
            }

        public static void main(String[] args){
            GameFrame gameFrame = new GameFrame();
            gameFrame.launch();
        }
    }

